package com.reservation.entity;

import javax.validation.constraints.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.LocalDateTime;

/**
 * 预订实体类
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class Reservation extends BaseEntity {

    @NotNull(message = "预订日期不能为空")
    private LocalDate reservationDate;

    @NotNull(message = "预订时间不能为空")
    private LocalTime reservationTime;

    @Min(value = 1, message = "人数必须大于0")
    @Max(value = 20, message = "人数不能超过20")
    private Integer personCount;

    @NotBlank(message = "联系人姓名不能为空")
    @Size(max = 50, message = "联系人姓名长度不能超过50个字符")
    private String contactName;

    @NotBlank(message = "联系电话不能为空")
    private String contactPhone;

    @Size(max = 255, message = "备注长度不能超过255个字符")
    private String remark;

    @NotNull(message = "订单金额不能为空")
    @DecimalMin(value = "0.01", message = "订单金额必须大于0")
    private BigDecimal totalAmount;

    // 预订状态：PENDING(待确认), CONFIRMED(已确认), CANCELLED(已取消), COMPLETED(已完成)
    private String status = "PENDING";

    // 订单号
    @NotBlank(message = "订单号不能为空")
    private String orderNumber;

    // 支付状态：UNPAID(未支付), PAID(已支付), REFUNDED(已退款)
    private String paymentStatus = "UNPAID";
    
    // 支付时间
    private LocalDateTime paymentTime;
    
    // 支付方式：WECHAT(微信支付), ALIPAY(支付宝), CASH(现金)
    private String paymentMethod;

    // 关联的用户ID
    private Long userId;
    
    // 关联的产品ID
    private Long productId;
    
    // 在内存中保存关联的用户和产品对象，不映射到数据库
    private transient User user;
    private transient Product product;
}
